package comment.dao.imp;

import comment.dao.IVideoDao;
import comment.model.pojo.Comment;
import comment.model.pojo.Reply;
import comment.model.pojo.Video;
import comment.until.JdbcTemplate;

import java.util.List;

public class VideoDaoImp implements IVideoDao {
    @Override
    public List<Video> getVideoByUid(int id) throws InstantiationException, IllegalAccessException {
        return JdbcTemplate.executeDQL(Video.class,"select * from t_video where user_id=?",id);
    }

    @Override
    public List<Comment> getCommentByVid(int vid) throws InstantiationException, IllegalAccessException {
        return JdbcTemplate.executeDQL(Comment.class,"select * from t_comment where video_id=?",vid);
    }

    @Override
    public List<Reply> getReplyByCommentId(int id) throws InstantiationException, IllegalAccessException {
        return JdbcTemplate.executeDQL(Reply.class,"select *from t_reply where comment_id =?",id);
    }

    @Override
    public void deleteVideoByVid(int vid) {
        JdbcTemplate.executeDML("delete from t_video where id=?",vid);
    }

    @Override
    public void deleteCommentBy(int vid) {
        JdbcTemplate.executeDML("delete from t_comment where video_id=?",vid);
    }

    @Override
    public void deleteReplyBy(int comid) {
        JdbcTemplate.executeDML("delete from t_reply where comment_id=?",comid);
    }
}
